#!../../../common/bats/bin/bats
# -*-sh-*-

load ../../../common/test_helper_functions || exit 1
source ../../../common/functions || exit 1

if [ -s ./TEST_ENV ];then
    source ./TEST_ENV
else
    ERROR "missing TEST_ENV"
fi

CMD_TIMEOUT="15:00"
TEST_EXE="./src/mini_dft"
TEST_MAX_COMPUTES=4
TEST_NUM_RANKS=4
TEST_NUM_THREADS=2
TEST_VERIFY=1
TEST_PERFLOG=./log.miniDFT

@test "[Apps/MiniDFT] build MiniDFT executable ($LMOD_FAMILY_COMPILER/$LMOD_FAMILY_MPI)" {
    # force delete exe
    rm -f $TEST_EXE $TEST_EXE.$LMOD_FAMILY_COMPILER.$LMOD_FAMILY_MPI >& /dev/null

    # build exe
    pushd src                  >& /dev/null
    make -f Makefile.ohpc clean >& /dev/null
    make -f Makefile.ohpc       >& /dev/null
    popd                       >& /dev/null

    if [ ! -s $TEST_EXE ];then
        flunk "failed to create $TEST_EXE"
    fi

    # rename exe
    cp -f $TEST_EXE $TEST_EXE.$LMOD_FAMILY_COMPILER.$LMOD_FAMILY_MPI
}
